/**
 * Created by Administrator on 2017/4/7 0007.
 */
var netElementData=[];
GameController={
    Create:function(){
        var GC={};

        function getData(){
            netElementData = [
                "A1qkd-1", "B", "A", 1, 1,1,2,
                "A2qkd-1", "B", "A", 2, 1,3,4,
                "A3qkd-1", "B", "A", 3, 1,5,1,
                "A4qkd-1", "B", "A", 4, 1,4,2,
                "A5qkd-1", "B", "A", 5, 1,5,3,
                "A6qkd-1", "B", "A", 1, 2,2,5,
                "A7qkd-1", "B", "A", 2, 2,1,6,
                "A8qkd-1", "B", "A", 3, 2,3,7,
                "A9qkd-1", "B", "A", 4, 2,5,4,
                "A10qkd-1", "B", "A", 5, 2,4,6,
                "B1qkd-2", "C", "B", 7, 1,5,3,
                "B2qkd-2", "C", "B", 8, 1,2,1,
                "B3qkd-2", "C", "B", 9, 1,2,2,
                "B4qkd-2", "C", "B", 10, 1,1,3,
                "B5qkd-2", "C", "B", 11, 1,1,5,
                "B6qkd-2", "C", "B", 7, 2,2,3,
                "B7qkd-2", "C", "B", 8, 2,2,1,
                "B8qkd-2", "C", "B", 9, 2,5,2,
                "B9qkd-2", "C", "B", 10, 2,2,5,
                "qvpn-1", "A", "C", 1, 4,3,6,
                "qvpn-2", "A", "C", 2, 4,4,7,
                "qvpn-3", "A", "C", 3, 4,4,5,
                "qvpn-4", "A", "C", 4, 4,5,4,
                "qvpn-5", "A", "C", 5, 4,5,2,
                "qvpn-6", "A", "C", 1, 5,1,1,
                "qvpn-7", "A", "C", 2, 5,1,2,
                "qvpn-8", "A", "C", 3, 5,2,2,
                "qsw-1", "E", "D", 7, 4,2,1,
                "qsw-2", "E", "D", 8, 4,3,3,
                "qsw-3", "E", "D", 9, 4,4,4,
                "qsw-4", "E", "D", 10, 4,4,5,
                "qrng-1", "D", "E", 1, 7,4,7,
                "qrng-2", "D", "E", 2, 7,3,6,
                "qrng-3", "D", "E", 3, 7,2,3,
                "qrng-4", "D", "E", 4, 7,2,1,
                "qrng-5", "D", "E", 5, 7,2,2,
                "qrng-6", "D", "E", 1, 8,1,1,
                "qrng-7", "D", "E", 2, 8,1,3
            ];
        }

        getData();



        document.addEventListener("showOrHideLine",function(e){
            // console.log(e.detail);
            document.dispatchEvent(new CustomEvent("showOrHideLine3D",{detail:e.detail}))
        })
        document.addEventListener("canMoveOrNot",function(e){
            // console.log(e.detail);
            document.dispatchEvent(new CustomEvent("canMoveOrNot3D",{detail:e.detail}))
        })
        document.addEventListener("ShowNetElementInfo",function(e){
            // console.log(e.detail.clickedIndex,e.detail.b);
            document.dispatchEvent(new CustomEvent("ShowNetElementInfo2D",{detail:e.detail.clickedIndex}))
            document.dispatchEvent(new CustomEvent("ShowNetElementInfo3D",{detail:e.detail.clickedIndex}))
        })
        document.addEventListener("CloseNetElementInfo",function(e){
            // console.log(e.detail);
            document.dispatchEvent(new CustomEvent("CloseNetElementInfo2D",{detail:e.detail}))
            document.dispatchEvent(new CustomEvent("CloseNetElementInfo3D",{detail:e.detail}))
        })
        document.addEventListener("autoPlayOrNot",function(e){
            document.dispatchEvent(new CustomEvent("autoPlayOrNot3D"))
        })



        // document.getElementById("Layer2D").style.zIndex=2;
        // document.getElementById("Layer3D").style.zIndex=1;



        // console.log("balabala");
        // console.log("balabala");
        // console.log("balabala");
        // console.log("balabala");
        // $.ajax({
        //     url: "http://192.168.8.218:8081/qnms/webgl/neList",
        //     type: 'POST',
        //     dataType: 'JSONP',//here
        //     success: function (data) {
        //         console.log(data);
        //         console.log("AJAXAJAX");
        //         console.log("AJAXAJAX");
        //         console.log("AJAXAJAX");
        //         console.log("AJAXAJAX");
        //     }
        // });



        function neList() {
            var xmlhttp = new XMLHttpRequest();
            xmlhttp.onreadystatechange = callback;
            var url = "http://192.168.8.218:8081/qnms/webgl/neList";
            xmlhttp.open("POST", url, true);
            xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");

            xmlhttp.send();
            function callback() {
                console.log(xmlhttp.status);
                if (xmlhttp.readyState == 4) {
                    if (xmlhttp.status == 200) {
                        var response = xmlhttp.responseText;
                        console.log(response);
                    }
                }
            }
        }
        // neList();

        function neRefresh(){
            var xmlhttp = new XMLHttpRequest();
            xmlhttp.onreadystatechange = callback;
            var url = "http://192.168.8.218:8081/qnms/webgl/neRefresh";
            xmlhttp.open("POST", url, true);
            xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
            xmlhttp.send();
            function callback() {
                console.log(xmlhttp.status);
                if (xmlhttp.readyState == 4) {
                    if (xmlhttp.status == 200) {
                        var response = xmlhttp.responseText;
                        console.log(response);
                    }
                }
            }
        }
        // neRefresh();

        // neInfo();
        function neInfo(){
            var xmlhttp = new XMLHttpRequest();
            xmlhttp.onreadystatechange = callback;
            var url = "http://192.168.8.218:8081/qnms/webgl/neInfo";
            xmlhttp.open("POST", url, true);
            xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");

            xmlhttp.send("neld="+0);
            function callback() {
                console.log(xmlhttp.status);
                if (xmlhttp.readyState == 4) {
                    if (xmlhttp.status == 200) {
                        var response = xmlhttp.responseText;
                        console.log(response);
                    }
                }
            }
        }





















        return GC;
    }
}